package com.xnj.file_buffer_stream_demo;

import java.io.BufferedWriter;
import java.io.FileWriter;

// 字符缓冲输出流，写出数据
public class BufferWriterTest {
    public static void main(String[] args) {
        try(
                FileWriter fw = new FileWriter("src/bufferwriter.txt",true);
                // 创建字符缓冲输出流对象
                BufferedWriter bw = new BufferedWriter(fw);
        ){

            bw.write('a');
            bw.write("你好啊");

            // 新增的方法：写入换行
            bw.newLine();

            char [] chr =  {'a', 'b', 'c'};
            bw.write(chr,2,1);

            bw.newLine();

            String str = "good time";
            bw.write(str,5,4);


        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
